﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Index_HomePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
            PartyFinderDBDataContext db = new PartyFinderDBDataContext();
            var id = Membership.GetUser();
            var participatingpartys = from u in db.aspnet_Users
                           join pp in db.PartyParticipants on u.UserId equals pp.UserId
                           join p in db.Parties on pp.PartyId equals p.PartyId
                           where u.UserName == id.UserName
                           select new {p.Date, p.Tema, p.PartyId};

            LWParticipatingPartys.DataSource = participatingpartys;
            LWParticipatingPartys.DataBind();

            var mypartys = from p in db.Parties
                           join u in db.aspnet_Users on p.UserId equals u.UserId
                           where u.UserName == id.UserName
                           select p;
            LWMyPartys.DataSource = mypartys;
            LWMyPartys.DataBind();

    }
    protected void CreateParty_Click(object sender, EventArgs e)
    {
        Response.Redirect("CreateParty.aspx");
    }
    protected void SearchParty_Click(object sender, EventArgs e)
    {
        Response.Redirect("FindParty.aspx");
    }
}